/**
 *     This file is part of cesm-ws.
 *
 *     cesm-ws, Web Service for Community Earth System Model
 *
 *     Copyright (c) 2010, Purdue University and/or affilicates or thrid-party contributors as
 *     indicated by the @author tags or express copyright attribution statements
 *     applied by the authors. All third-party contributions are distributed under
 *     license by Purdue University.
 *
 *     cesm-ws is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this distribution.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.purdue.rcac.cesm.define;

/**
 * This is enumeration of valid values for createCase input field 'resolution'.
 * This class is written in accordance with 'create_newcase -list' output for
 * CCSM 4.0 scripts.
 * 
 * @author Han Zhang
 * 
 */
public enum Resolution {
	//
	pt1("pt1_pt1"),

	//
	f05_f05("0.47x0.63_0.47x0.63"),

	//
	f05_g16("0.47x0.63_gx1v6"),

	//
	f05_t12("0.47x0.63_tx0.1v2"),

	//
	f09_f09("0.9x1.25_0.9x1.25"),

	//
	f09_g16("0.9x1.25_gx1v6"),

	//
	f19_f19("1.9x2.5_1.9x2.5"),

	//
	f19_g16("1.9x2.5_gx1v6"),

	//
	f45_f45("4x5_4x5"),

	//
	f45_g37("4x5_gx3v7"),

	//
	T62_g37("T62_gx3v7"),

	//
	T62_t12("T62_tx0.1v2"),

	//
	T62_g16("T62_gx1v6"),

	//
	T31_T31("T31_T31"),

	//
	T31_g37("T31_gx3v7"),

	//
	T42_T42("T42_T42"),

	//
	f10_f10("10x15_10x15"),

	//
	ne30_f19_g16("ne30np4_1.9x2.5_gx1v6");

	private String fullName;

	private Resolution(String fullName) {
		this.fullName = fullName;
	}

	/**
	 * This method replaces '-' with '_' and returns Resolution enum type object
	 * if input string matches name or fullName.
	 * 
	 * @param nameOrFullName
	 * @return
	 * @throws IllegalArgumentException
	 */
	public static Resolution fromString(String nameOrFullName)
			throws IllegalArgumentException {
		for (Resolution r : Resolution.values()) {
			if (r.name().equalsIgnoreCase(nameOrFullName)
					|| r.fullName.equalsIgnoreCase(nameOrFullName))
				return r;
		}
		throw new IllegalArgumentException("Can not match '" + nameOrFullName
				+ "' to enum Resolution");
	}
}